package main
 
import (
    "fmt"
    "net"
)
 
func main() {
    targetIP := "192.168.0.1"
    targetPort := 22
    username := "root"
    password := "password"
 
    conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", targetIP, targetPort))
    if err != nil {
        fmt.Println("Error connecting to target:", err)
        return
    }
 
    defer conn.Close()
 
    fmt.Println("Connected to target")
 
    buf := make([]byte, 1024)
    n, err := conn.Read(buf)
    if err != nil {
        fmt.Println("Error reading from target:", err)
        return
    }
 
    fmt.Println(string(buf[:n]))
 
    conn.Write([]byte(fmt.Sprintf("%s\n", username)))
    n, err = conn.Read(buf)
    if err != nil {
        fmt.Println("Error reading from target:", err)
        return
    }
 
    fmt.Println(string(buf[:n]))
 
    conn.Write([]byte(fmt.Sprintf("%s\n", password)))
    n, err = conn.Read(buf)
    if err != nil {
        fmt.Println("Error reading from target:", err)
        return
    }
 
    if string(buf[:n]) == "Access granted\n" {
        fmt.Println("Login successful!")
    } else {
        fmt.Println("Login failed")
    }
}